/* Copyright (C) 2025 Griefed
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
 * USA
 *
 * The full license can be found at https:github.com/Griefed/ServerPackCreator/blob/main/LICENSE
 * full license can be found at https:github.com/Griefed/ServerPackCreator/blob/main/LICENSE
 */
package de.griefed.serverpackcreator.app.gui.splash

import de.griefed.serverpackcreator.app.gui.utilities.ImageUtilities
import javax.swing.JButton
import kotlin.system.exitProcess

/**
 * Display an exit button in the splash screen to quit SPC before it is fully started.
 *
 * @author Griefed
 */
class ExitButton(width: Int) : JButton() {
    init {
        val size = 16
        @Suppress("SpellCheckingInspection")
        icon = ImageUtilities.fromBase64(
            "iVBORw0KGgoAAAANSUhEUgAAAQcAAAEGCAYAAAEf8GCUAAAABGdBTUEAALGPC/xhBQAAAYVpQ0NQSUNDIHByb2ZpbGUAACiRfZE9SMNAHMVf00pFKoJ28GvIUHWxICriKFUsgoXSVmjVweTSL2jSkKS4OAquBQc/FqsOLs66OrgKguAHiKOTk6KLlPi/tNAixoPjfry797h7Bwi1ElNN3wSgapaRiEbEdGZV9L/ChwH0YgxDEjP1WHIxBdfxdQ8PX+/CPMv93J+jW8maDPCIxHNMNyziDeKZTUvnvE8cZAVJIT4nHjfogsSPXJcb/MY577DAM4NGKjFPHCQW820stzErGCrxNHFIUTXKF9INVjhvcVZLFda8J39hIKutJLlOcxhRLCGGOETIqKCIEiyEadVIMZGg/YiLf9Dxx8klk6sIRo4FlKFCcvzgf/C7WzM3NdlICkSAjhfb/hgB/LtAvW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zlsJISSAFpmZJ1CWFnpJACkzNkqhbCkckgRSYmiXxnSUp/B8yh5zR4BariQAAAABJRU5ErkJggg==",
            size, size
        )
        setBounds(width - size - 5, 5, size, size)
        isContentAreaFilled = false
        isOpaque = false
        border = null
        isBorderPainted = false
        addActionListener { exitProcess(0) }
    }
}